<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<spring:url value="/images/add.png" var="add"></spring:url>
<spring:url value="/images/mail.png" var="mail"></spring:url>
<spring:url value="/images/glyphicons_150_edit.png" var="edit"></spring:url>
<spring:url value="/images/" var="images"></spring:url>

<script src="${jsUrl}" type="text/javascript"></script>
<spring:url value="/js/ricerca" var="ricercajs"></spring:url>
<script src="${ricercajs}/news-ext.js"></script>
<script>

	function cambiaPagDati(page){
		
		document.getElementById("pagina").value=page;
		document.getElementById("oppAzienda").submit();
	}

</script>
<div class="unit-row">
	<nav class="nav-tabs" style="width:1000px">
			<ul>
				<ul>
				<li><a href="${flowExecutionUrl}&_eventId=dati-anagrafici">Dati anagrafici</a></li>
				<li><a href="${flowExecutionUrl}&_eventId=contatti-azienda">Contatti</a></li>
				<li><span>Opportunit&agrave;</span></li>			
				<li><a href="<c:url value="j_spring_security_logout" />">Logout</a></li>
			</ul>		
			</ul>
		</nav>
		<br />

		<div class="unit-100 unit-centered" style="width:800px">
			<h3 class="head-toc head-toc-start">Opportunit&agrave; Azienda</h3>
			<div id="emailContainer"></div>
			<form:form id="oppAzienda" cssClass="forms forms-columnar"
				action="${flowExecutionUrl}" method="POST" commandName="opportunitaForm" >
				<form:hidden path="searched"/>				
				<c:set var="oppList" value="${opportunitaForm.opps}" scope="session" />
 				<c:out value="${pagedBanner}" escapeXml="false"></c:out> 
				
				<table style="margin:auto;width:750px">
				<tr>
					<td>
						<table style="margin:auto;">
							<tr>
								<td style="width:25px;border:0">
									&nbsp;
								</td>
								<td style="width:200px;border:0">
									Codice
								</td>	
								<td style="width:125px;border:0">
									Progressivo
								</td>
								<td style="width:125px;border:0">
									Descrizione
								</td>
								<td style="width:125px;border:0">
									Azioni
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td colSpan="6" style="width:750px;padding-left:0px;padding-right:0px;">
						<div style="width:100%;overflow-y:scroll;height:200px;">
							<table style="text-align:left;">
								<c:forEach var="recordOpp" items="${oppList}" varStatus="opportunita" begin="0" >
									<tr>
										<td style="width:25px;border:0">
											<c:out value="${recordOpp.codice}"></c:out>
										</td>
										<td style="width:200px;text-align:center;padding-left:20px;padding-right:0px;">
											<c:out value="${recordOpp.progressivo}"></c:out>
										</td>
										<td style="width:125px;text-align:center;padding-left:20px;padding-right:0px;">
											<c:out value="${recordOpp.descrizione}"></c:out>
										</td>																				
										<td style="width:125px;text-align:center;padding-left:20px;padding-right:0px;">
											<a href="${flowExecutionUrl}&_eventId=dettaglioOpportunita&idOpportunita=${recordOpp.idOpportunita}&idAzienda=${recordOpp.azienda.idAzienda}">
													<img alt="Visualizza opportunita" src="${edit}" border="0">
											</a>
										</td>				
									</tr>
								</c:forEach>	
							</table>
						</div>
					</td>
				</tr>
			</table>
			
			<p class="forms-inline">
				<form:hidden id="pagina" path="pagina"/>
				<form:hidden path="recordPerPagina" />
				<input type="hidden" name="_eventId" id="eventId" value="refreshOpportunita"> 
			</p>
			
			<p align="right">
				<a href="${flowExecutionUrl}&_eventId=nuovaOpportunita&idAzienda=${idAzienda}">Nuova Opportunit&agrave;</a>
			</p>
		</form:form>
	</div>
	
</div>